<?php

namespace App\Console\Commands\OpenShop\Ekb;

use App\Imports\Ekb\SupplierShopCodeRelImport;
use Illuminate\Console\Command;
use Maatwebsite\Excel\Facades\Excel;

class GenerateSupplierShopCodeRelCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'ekb:generateSupplierShopCodeRelCommand';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '易快报 - 生成供应商门店关联关系';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {


        $filePath = downloadFile(
            "https://file.51kuafu.com/28/75/a029787825e0202047f5958da7dd90cc967e3c269d769f17488780a95f23.xlsx",
            "ekb",
            "supplierShopCodeRel",
            "xlsx"
        );

        $this->getOutput()->info($filePath);
        Excel::import(new SupplierShopCodeRelImport(), $filePath);
        return 0;
    }
}
